<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href='<?php echo base_url()?>'>
<link rel="stylesheet" type="text/css" href="public/common/css/common.css"/>
<link rel="stylesheet" type="text/css" href="public/admin/css/admin.css"/>
<script src="public/common/js/jquery.js"></script>
<script>
$(function(){
	$('.table tr').hover(function(){
		$(this).children('td').css('background','#ccffcc');
	},function(){
		$(this).children('td').css('background','white');
	});		   
});
function del(obj,category_id)
{
	if($(obj).parent().parent().children('td').eq(1).text() == '默认')
	{
		alert('不能删除默认分类');
	}else{
		$.get('<?php echo site_url("admin/ad/delete_category")?>/'+category_id,function(result){
			if(result == 1)
			{
				$(obj).parent().parent().remove();
			}
		});
	}
	
}
function go_edit(obj,category_id)
{
	if($(obj).parent().parent().children('td').eq(1).text() == '默认')
	{
		alert('不能修改默认分类');
	}else{
		location.href="<?php echo site_url('admin/ad/category_edit')?>"+"/"+category_id;
	}
	
}
</script>
</head>
<body>
	<div class="body">
    	<?php echo $this->position->get_position();?>
        <div class="go_back"><a href="<?php echo site_url('admin/ad/category_add')?>">新增分类</a></div>
    	<div class="body_center">
        	
            <table class="table" style="margin-bottom:0px;">
            	<tr><th>分类ID</th><th>分类名称</th><th>操作</th></tr>
				<?php foreach($category->result() as $value):?>
				<tr><td class="center"><?php echo $value->category_id?></td><td class="center"><?php echo $value->category_name?></td><td class="center"><a href="javascript:void(0)" onclick='go_edit(this,"<?php echo $value->category_id?>")'>修改</a> | <a onclick="del(this,'<?php echo $value->category_id?>')" href="javascript:void(0)">删除</a></td></tr>
				<?php endforeach;?>
            </table>
        </div>
    </div>
</body>
</html>